package com.example.service;

import com.example.entity.User;
import com.example.mapper.UserMapper;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 何星霖
 * @date 2018/10/15 9:42
 */
@Service
@Slf4j
public class UserService {

    @Autowired
    private UserMapper userMapper;
    public int insert(String name, Integer age) {
        System.out.println("name="+name+"serviceage="+age);
        int a=userMapper.insert(name,age);
        log.info("-----------a-----------",a);
        return  a;
    }
    public List<User> findByName(String name){
        return userMapper.findByName(name);
    }
    public PageInfo<User> findUserList(int page, int size){
        PageHelper.startPage(page, size);
        List<User> userList=userMapper.findUserList();
        PageInfo<User> pageInfo=new PageInfo<User>(userList);
        return pageInfo;
    }
}
